<?php

/**
 * @name DashboardController.php
 */
class DashboardController extends AppController
{
    # Controller name

    var $name = 'Dashboard';
    # set the model to use
    var $uses = array('User');
    # Set the layout to use
    var $layout = 'dashboard_layout';

    function index()
    {

        $user_type = $this->Auth->user('user_type');
        $user_level = $this->Auth->user('user_level');
        if ($user_type == 'admin') {
            $this->redirect(array('controller' => 'Administration', 'action' => 'index'));
        }
        elseif ($user_type == 'accountant') {

        }
        elseif ($user_type == 'store') {

        }
        elseif ($user_type == 'warehouse') {

        }
        elseif ($user_type == 'service_adviser') {
            $this->redirect(array('controller' => 'ServiceAdviser', 'action' => 'index'));
        }
        elseif ($user_type == 'workshop') {

        }
        else { //This will prevent users without purpose
            $this->redirect(array('controller' => 'Users', 'action' => 'logout'));
        }
    }
}